package com.ruoyi.web.admin.data.command;

import com.ruoyi.web.admin.data.Constants;
import com.ruoyi.web.admin.data.utils.CommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

/**
 * 设备模式上报处理器
 *
 * @author 10100
 */
@Component
public class DeviceStatusCommandHandler implements CommandHandler {


    private static final Logger log = LoggerFactory.getLogger(DeviceStatusCommandHandler.class);

    @Override
    public String handle(String deviceId, String iccid, String recordId, String command,
                         String type, String timestamp, String length, String body) {
        log.info("设备[{}]切换模式: {}, 说明: 0 待机模式,1 省电模式,2 平衡模式,3 实时模式", deviceId, body);

        // 构建响应格式
        String responseBody = "0";
        return "[" + deviceId + "," +
                iccid + "," +
                CommonUtils.generateSerialNumber() + "," +
                command + "," +
                Constants.REPORT_RESPONSE + "," +
                CommonUtils.getCurrentTimestamp() + "," +
                responseBody.length() + "," +
                responseBody + "]";
    }

    @Override
    public String getCommandType() {
        return "DEVICE_STATUS";
    }
}